﻿using Sunny.UI;
using System;
using System.Windows.Forms;

namespace RM.Weighing
{
    public partial class UIRegister : UIForm
    {
        public UIRegister()
        {
            InitializeComponent();
        }

        private void uiTextBox1_Click(object sender, EventArgs e)
        {
            uiTextBox1.SelectAll();
            Clipboard.SetDataObject(uiTextBox1.Text);
            ShowSuccessTip("已复制机器码：\r\n" + uiTextBox1.Text);
        }

        private void UIRegister_Load(object sender, EventArgs e)
        {
            string Register = new Tools().ObtainMachineCode();
            uiTextBox1.Text = Register;
        }

        private void uiButton1_Click(object sender, EventArgs e)
        {
            string data = uiTextBox2.Text;
            string regisData = new Tools().GetRegistrationCode(new Tools().ObtainMachineCode());
            if (regisData.Equals(data))
            {
                Tools.GetSystemInfo.SetRegistData("Weighing", regisData);
                DialogResult = DialogResult.OK;
                Close();
            }
            else
            {
                MessageBox.Show("注册码验证错误，请重新输入！");
            }
        }
    }
}
